<?php
use yii\helpers\Url;
\backend\assets\PickerAsset::register($this);
use common\models\PercentageItem\PercentageItem;
?>
<?php $this->beginBlock('content') ?>
<div class="row">
   <div class="col-sm-12">
        <div class="white-box">
            <h3 class="box-title"></h3>
            <div class="row m-b-15">
                <div class="col-sm-10">
                    <form action="">
                        <div class="row">

                            <div class="col-sm-3">
                                <div class="form-group">
                                    <select class="selectpicker" data-live-search="true" name="agent_status">
                                        <option value="">分成状态</option>
                                        <option value="<?=PercentageItem::STATUS_YES?>" <?=Yii::$app->request->get('agent_status') == PercentageItem::STATUS_YES ? 'selected' : ''?>>已分成</option>
                                        <option value="<?=PercentageItem::STATUS_NO?>" <?=Yii::$app->request->get('agent_status') === (string)PercentageItem::STATUS_NO ? 'selected' : ''?>>未分成</option>

                                    </select>
                                </div>
                            </div>
                            <div class="col-sm-4">
                                <div class="input-group">
                                    <input type="text" class="form-control m-r-5 dateInputs" rel-format="yyyy-MM" name="ym"  value="<?=Yii::$app->request->get('ym')?>" placeholder="年月 如 <?=date("Y-m")?>">
                                    <input type="text" class="form-control m-r-5"  name="agent_id"  value="<?=Yii::$app->request->get('agent_id')?>" placeholder="代理商ID">
                                    <span class="input-group-btn">
                                        <button class="btn btn-info" type="submit">
                                            搜索
                                        </button>
                                    </span>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>

            </div>
            <div>合计终端数：<?=intval(@$totalRet["terminal_num"])?></div>
            <br>
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                    <tr>
                        <th>Agent ID</th>
                        <th>时间</th>
                        <th>代理名称</th>
                        <th>联系电话</th>
                        <th>累计终端数</th>
                        <th>昨日终端数</th>
                        <th>收钱码</th>
                        <?php if (\common\models\Admin\Admin::isAdminCurrent()) : ?>
                        <th>操作</th>
                        <?php endif ?>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach ($ret as $item): ?>
                    <tr>
                        <td><?=$item["agent_id"]?></td>
                        <td><?=$item["created_ym"]?></td>
                        <td>
                            <?=$item["agentInfo"]["name"]?>
                        </td>
                        <td>
                            <?=$item["agentInfo"]["ali_account"]?>
                        </td>
                       <td><?=$item["terminal_num"]?></td>
                        <td><?=intval($item["yesterdayAgentNum"]["terminal_num"])?></td>
                        <td>
                            <?php if ($item["agentInfo"]["rev_price_image"]) : ?>
                                <a href="<?=Url::to(["/attachment/show-img", "url" => $item["agentInfo"]["rev_price_image"],  "w" => "400", "h" => "500"])?>" rel-action="open" rel-title="收钱码">点击查看</a>
                            <?php else :?>
                                无
                            <?php endif ?>
                        </td>
                        <?php if (\common\models\Admin\Admin::isAdminCurrent()) : ?>
                        <td>
                            <?php if ($item["agent_status"] != \common\models\PercentageItem\PercentageItem::STATUS_YES) : ?>
                                <a href="<?=Url::to(["settlement", "uid" => $item["agent_id"], "type" => "agent", "ym" => $item["created_ym"]])?>"   data-toggle="tooltip" data-original-title="确认分成" rel-action="prompt" rel-title="您确定要分成吗？"> 确认分成 </a>
                            <?php else :?>
                                <span style="color: green">已分成</span>
                            <?php endif ?>
                        </td>
                        <?php endif ?>
                    </tr>
                    <?php endforeach ?>
                    </tbody>
                    <tfoot>
                    <tr>
                        <td colspan="14" class="footable-visible">
                            <div class="text-right">
                                <?=\common\components\DataHelper::getLinkPager($page)?>
                            </div>
                        </td>
                    </tr>
                    </tfoot>
                </table>
            </div>
        </div>
    </div>
</div>
<?php $this->endBlock()?>
